<?php

namespace app\api\model;

use think\Model;

/**
 * Banner
 */
class HotelOrder extends Model
{
    // 表名
    protected $name = 'hotel_order';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = true;

    public function getUserHotelOrder($member,$member_vip_card,$hotel_id){
        $map[] = ['member_id' ,'=',$member['id']];
        $map[] = ['hotel_id' ,'=',$hotel_id];
        $map[] = ['status' ,'in', [1,2,3,4]];
        $map[] = ['create_time','>',$member_vip_card['update_time']];
        $map[] = ['create_time','<',$member_vip_card['expire_time']];
        return  (new HotelOrder())->where($map)->count();
    }


    public function getLastOrder($member_id){
        $map[] = ['status' ,'in', [1,2]];
        $map[] = ['member_id' ,'=',$member_id];

        return  (new HotelOrder())->where($map)->order('id desc')->find();
    }


    public function getOrderNums($member_id){
        $map[] = ['member_id' ,'=',$member_id];
        $map[] = ['status' ,'=',4];
        return  (new HotelOrder())->where($map)->order('id desc')->value('nums') ?? 0;

    }


}
